<template>
    <el-form :model="activityForm" :inline="true" style="margin-bottom: 10px;" class="demo-form-inline">
        <el-form-item label="培训名称">
            <el-input v-model="activityForm.trainingName" style="width: 120px;" placeholder="请输入培训名称" />
        </el-form-item>
        <el-form-item label="活动状态">
            <el-select v-model="activityForm.activityStatus" style="width: 100px;" placeholder="请选择">
                <el-option label="正在进行" value="1"></el-option>
                <el-option label="已经结束" value="2"></el-option>
            </el-select>
        </el-form-item>
        <el-form-item label="开展时间">
            <el-date-picker v-model="activityForm.startTime" value-format="YYYY-MM-DD" type="daterange"
                placeholder="选择日期" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"
                style="margin-left: 10px"></el-date-picker>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="getTrainingActivityMsg">查询</el-button>
            <el-button type="info" @click="clearActivityForm">清空</el-button>
        </el-form-item>
    </el-form>
    <div style="justify-content: space-between;">
        <el-button type="primary" @click="dialogVisible = true">新增培训活动</el-button>
        <el-button type="danger" @click="deleteTrainingActivityMsgByIds">批量删除</el-button>
    </div>
    <div>
        <el-table :data="tableData" border style="width: 88%;margin-bottom: 10px;margin-top: 10px;"
            @selection-change="getTrainingActivityMsgBySelect">
            <el-table-column type="selection" width="55" />
            <el-table-column type="index" label="id" width="55" />
            <el-table-column property="trainingName" label="培训名称" width="120" />
            <el-table-column property="trainingPlan" label="培训计划" width="120">
                <template #default="scope">
                    <el-tooltip class="item" effect="dark" :content="scope.row.trainingPlan" placement="top">
                        <span>{{
                            scope.row.trainingPlan.length > 10 ? scope.row.trainingPlan.slice(0, 10) + '...' :
                                scope.row.trainingPlan }}</span>
                    </el-tooltip>
                </template>
            </el-table-column>
            <el-table-column property="maxCapacity" label="人数上限" width="120" />
            <el-table-column property="actualAttendance" label="实际参加人数" width="120" />
            <el-table-column property="startTime" label="开展时间" width="120">
                <template #default="scope">
                    {{ moment(scope.row.startTime).format('YYYY-MM-DD') }}
                </template>
            </el-table-column>
            <el-table-column property="endTime" label="结束日期" width="120" />
            <el-table-column property="activityStatus" label="活动状态" width="120">
                <template #default="scope">
                    <span v-if="scope.row.activityStatus === 1">正在进行</span>
                    <span v-else-if="scope.row.activityStatus === 2">已经结束</span>
                </template>
            </el-table-column>
            <el-table-column style="justify-content: space-between;" label="操作">
                <template #default="scope">
                    <el-link style="margin-right:10px ;" target="_blank"
                        @click="getEmpTrainingActivityId(scope.row.id)">查看</el-link>
                    <el-link type="primary" style="margin-right: 10px;"
                        @click="getTrainingActivityMsgById(scope.row.id)">修改</el-link>
                    <el-link type="danger" @click="deleteTrainingActivityMsgById(scope.row.id)">删除</el-link>
                </template>
            </el-table-column>
        </el-table>
    </div>
    <div style="margin-top: 10px;">
        <el-pagination v-model:current-page="currentPage" v-model:page-size="pageSize" :page-sizes="[5, 10, 15, 20]"
            :size="size" :disabled="disabled" :background="background" layout="total, sizes, prev, pager, next, jumper"
            :total="total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
    </div>
    <!--  新增培训活动对话框-->
    <el-dialog v-model="dialogVisible" title="新增培训活动" width="500" draggable>
        <el-form ref="ruleFormRef" style="max-width: 600px" :model="ruleForm" :rules="rules" label-width="auto"
            class="demo-ruleForm" :size="formSize" status-icon>
            <el-form-item label="培训活动" prop="trainingName">
                <el-input style="width: 150px;" v-model="ruleForm.trainingName" placeholder="请输入培训活动名称" clearable />
            </el-form-item>
            <el-form-item label="人数上限" prop="maxCapacity">
                <el-input style="width: 150px;" v-model="ruleForm.maxCapacity" placeholder="请输入上限人数数量" clearable />
            </el-form-item>
            <el-form-item label="开展时间" prop="startTime">
                <el-date-picker v-model="ruleForm.startTime" style="width: 150px;" type="date" placeholder="请选择开展时间"
                    clearable />
            </el-form-item>
            <el-form-item label="结束时间" prop="endTime">
                <el-date-picker v-model="ruleForm.endTime" type="date" style="width: 150px;" placeholder="请选择结束时间"
                    clearable />
            </el-form-item>
            <el-form-item label="培训计划" prop="trainingPlan">
                <el-input v-model="ruleForm.trainingPlan" style="width: 150px" autosize type="textarea"
                    placeholder="请输入培训计划" />
            </el-form-item>
            <el-form-item
                style="justify-content: space-between;justify-content: center;align-items: center;display: flex;">
                <el-button type="primary" @click="addTrainingActivity">确定</el-button>
                <el-button @click="resetForm(ruleFormRef)">清空</el-button>
            </el-form-item>
        </el-form>
    </el-dialog>
    <!-- 修改培训活动对话框 -->
    <el-dialog v-model="modifyDialogVisible" title="新增培训活动" width="500" draggable>
        <el-form ref="ruleFormRef" style="max-width: 600px" :model="modifyForm" :rules="rules" label-width="auto"
            class="demo-ruleForm" :size="formSize" status-icon>
            <el-form-item label="培训活动" prop="trainingName">
                <el-input style="width: 150px;" v-model="modifyForm.trainingName" placeholder="请输入培训活动名称" />
            </el-form-item>
            <el-form-item label="人数上限" prop="maxCapacity">
                <el-input style="width: 150px;" v-model="modifyForm.maxCapacity" placeholder="请输入上限人数数量" />
            </el-form-item>
            <el-form-item label="开展时间" prop="startTime">
                <el-date-picker v-model="modifyForm.startTime" type="date" placeholder="请选择开展时间" style="width: 150px;"
                    clearable />
            </el-form-item>
            <el-form-item label="结束时间" prop="endTime">
                <el-date-picker v-model="modifyForm.endTime" type="date" placeholder="请选择结束时间" style="width: 150px;" />
            </el-form-item>
            <el-form-item label="活动状态" prop="activityStatus">
                <el-select v-model="modifyForm.activityStatus" style="width: 150px;" placeholder="请选择活动状态">
                    <el-option label="正在进行" value="1" />
                    <el-option label="还未开展" value="2" />
                </el-select>
            </el-form-item>
            <el-form-item
                style="justify-content: space-between;justify-content: center;align-items: center;display: flex;">
                <el-button type="primary" @click="modifyTrainingActivityMsg">确定</el-button>
                <el-button @click="clearModifyForm()">清空</el-button>
            </el-form-item>
        </el-form>
    </el-dialog>
    <!-- 表格对话框 -->
    <el-dialog v-model="tableDialogVisible" title="活动情况" style="width: 90%;" draggable>
        <el-form :model="table" :inline="true" style="margin-bottom: 10px;" class="demo-form-inline">
            <el-form-item label="员工名称">
                <el-input v-model="table.name" style="width: 150px;" placeholder="请输入员工名称" />
            </el-form-item>
            <el-form-item label="员工性别">
                <el-select v-model="table.gender" style="width: 100px;" placeholder="请选择">
                    <el-option label="男" value="1"></el-option>
                    <el-option label="女" value="2"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="员工账号">
                <el-input v-model="table.account" style="width: 150px;" placeholder="请输入员工账号" />
            </el-form-item>
            <el-form-item label="报名时间">
                <el-date-picker v-model="table.registrationTime" value-format="YYYY-MM-DD HH:mm:ss" type="datetimerange"
                    range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" :size="size" />
            </el-form-item>
            <el-form-item label="活动得分">
                <el-input v-model="table.activityScore" style="width: 150px;" placeholder="请输入活动得分" />
            </el-form-item>
            <el-form-item label="活动时长">
                <el-input v-model="table.activityDuration" style="width: 150px;" placeholder="请输入活动时长" />
            </el-form-item>
            <el-form-item label="活动状态">
                <el-select v-model="table.activityStatus" clearable style="width: 100px;" placeholder="请选择">
                    <el-option label="正在进行" value="1"></el-option>
                    <el-option label="已经结束" value="2"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="getEmpTrainingActivityMsg">查询</el-button>
                <el-button type="info" @click="clearTable">清空</el-button>
            </el-form-item>
        </el-form>
        <div style="margin-top: 10px;">
            <el-button type="danger" @click="deleteEmpTrainingActivityMsgByIds">批量删除</el-button>
        </div>
        <el-table :data="userTableData" border style="width: 100%;margin-bottom: 10px;margin-top: 10px;"
            @selection-change="getEmpTrainingActivityMsgBySelect">
            <el-table-column type="selection" width="55" />
            <el-table-column type="index" label="id" width="100" />
            <el-table-column property="trainingName" label="活动名称" width="120" />
            <el-table-column property="name" label="员工姓名" width="120" />
            <el-table-column property="gender" label="员工性别" width="120">
                <template #default="scope">
                    <span v-if="scope.row.gender === 1">男</span>
                    <span v-else-if="scope.row.gender === 2">女</span>
                </template>
            </el-table-column>
            <el-table-column property="account" label="员工账号" width="120" />
            <el-table-column property="registrationTime" label="报名时间" width="200">
                <template #default="scope">
                    {{ moment(scope.row.registrationTime).format('YYYY-MM-DD HH:mm:ss') }}
                </template>
            </el-table-column>
            <el-table-column property="activityDuration" label="活动时长" width="120" />
            <el-table-column property="activityScore" label="员工得分" width="120" />
            <el-table-column property="activityStatus" label="活动状态" width="120">
                <template #default="scope">
                    <span v-if="scope.row.activityStatus === 0">未开始活动</span>
                    <span v-else-if="scope.row.activityStatus === 1">正在活动中</span>
                    <span v-else-if="scope.row.activityStatus === 2">已经结束活动</span>
                </template>
            </el-table-column>
            <el-table-column style="justify-content: space-between;" label="操作">
                <template #default="scope">
                    <el-link type="primary" style="margin-right: 10px;"
                        @click="getEmpTrainingActivityScoreByAccount(scope.row.account)">打分</el-link>
                    <el-link type="danger" @click="deleteEmpTrainingActivityMsgById(scope.row.account)">删除</el-link>
                </template>
            </el-table-column>
        </el-table>
        <div style="margin-top: 10px;">
            <el-pagination v-model:current-page="empCurrentPage" v-model:page-size="empPageSize"
                :page-sizes="[5, 10, 15, 20]" :size="size" :disabled="disabled" :background="background"
                layout="total, sizes, prev, pager, next, jumper" :total="empTotal" @size-change="empHandleSizeChange"
                @current-change="empHandleCurrentChange" />
        </div>
        <!-- 员工活动打分 -->
        <el-dialog v-model="scoreDialogVisible" title="员工分数" style="width: 40%;" draggable>
            <el-input v-model="score" placeholder="请输入员工培训得分" style="width: 160px;" />
            <el-button type="primary" style="margin-left: 10px;" @click="mark">确定</el-button>
            <el-button type="info" style="margin-left: 10px;" @click="mark">取消</el-button>
        </el-dialog>
    </el-dialog>
</template>

<script setup lang="ts">
import type { ComponentSize, FormInstance, FormRules } from 'element-plus'
import moment from 'moment';
import { ref, reactive, onMounted, watch } from 'vue'
import { ElMessage } from 'element-plus'
import axios from '@/utils/request';
const background = ref(true)
const dialogVisible = ref(false)
const currentPage = ref(1)
const pageSize = ref(10)
const total = ref(0)
const empCurrentPage = ref(1)
const empPageSize = ref(10)
const empTotal = ref(0)
const size = ref<ComponentSize>('default')
const disabled = ref(false)
const formSize = ref<ComponentSize>('default')
const ruleFormRef = ref<FormInstance>()
const tableDialogVisible = ref(false)
const scoreDialogVisible = ref(false)
const modifyDialogVisible = ref(false)

let activityForm = ref({
    trainingName: '',
    activityStatus: '',
    startTime: ['', ''],
})
const clearActivityForm = () => {
    activityForm.value = {
        trainingName: '',
        activityStatus: '',
        startTime: ['', ''],
    }
    //刷新表格
    getTrainingActivityMsg()
}
const ruleForm = reactive({
    trainingName: '',
    maxCapacity: '',
    startTime: '',
    endTime: '',
    trainingPlan: ''
})
let modifyForm = reactive({
    id: '',
    trainingName: '',
    maxCapacity: '',
    startTime: '',
    endTime: '',
    activityStatus: ''
})
const clearModifyForm = () => {
    modifyForm = reactive({
        id: '',
        trainingName: '',
        maxCapacity: '',
        startTime: '',
        endTime: '',
        activityStatus: ''
    })
}
const tableData = ref([])
const userTableData = ref([])
let table = reactive(
    {
        name: '',
        gender: '',
        account: '',
        registrationTime: ['', ''],
        activityDuration: '',
        activityStatus: '',
        activityScore: ''
    })
//清空表格
const clearTable = () => {
    table = reactive(
        {
            name: '',
            gender: '',
            account: '',
            registrationTime: ['', ''],
            activityDuration: '',
            activityStatus: '',
            activityScore: ''
        })
    //刷新表格
    getEmpTrainingActivityMsg();
}
//当前培训活动表页码改变
//组件挂载完成后执行
onMounted(() => {
    getTrainingActivityMsg()
})
const handleCurrentChange = (val: number) => {
    currentPage.value = val
    //刷新表格
    getTrainingActivityMsg()
}
//当前培训活动表展示页数改变
const handleSizeChange = (val: number) => {
    pageSize.value = val
    //刷新表格
    getTrainingActivityMsg()
}
//员工培训活动表页码改变
const empHandleCurrentChange = (val: number) => {
    empCurrentPage.value = val
    //刷新表格
    getEmpTrainingActivityMsg()
}
//员工培训活动表展示页数改变
const empHandleSizeChange = (val: number) => {
    empPageSize.value = val
    //刷新表格
    getEmpTrainingActivityMsg()
}
const rules = reactive<FormRules>({
    trainingName: [
        { required: true, message: '请输入团建活动名称', trigger: 'blur' },
    ],
    maxCapacity: [
        { required: true, message: '请输入人数', trigger: 'blur' },
        { min: 0, message: '人数必须大于零', trigger: 'blur' }
    ],
    startTime: [
        { required: true, message: '请选择时间', trigger: 'change' },
    ],
    endTime: [
        { required: true, message: '请选择时间', trigger: 'change' },
    ],
    activityStatus: [
        { required: true, message: '请选择活动状态', trigger: 'change' }
    ],
    trainingPlan: [
        { required: true, message: '请输入团建活动计划', trigger: 'blur' },
    ],
})
const resetForm = (formEl: FormInstance | undefined) => {
    if (!formEl) return
    formEl.resetFields()
}
//获取培训活动的信息
const getTrainingActivityMsg = async () => {
    //发送请求
    try {
        const result = await axios.get(`/admin/trainingActivity?page=${currentPage.value}&pageSize=${pageSize.value}&trainingName=${activityForm.value.trainingName}&activityStatus=${activityForm.value.activityStatus}
        &startTime=${activityForm.value.startTime[0]}&endTime=${activityForm.value.startTime[1]}`)
        if (result.data.code === 1) {
            //判断是否是查询
            if (activityForm.value.trainingName !== '' || activityForm.value.activityStatus !== '' || activityForm.value.startTime[0] !== '' || activityForm.value.startTime[1] !== '') {
                ElMessage.success('查询成功')
            }
            tableData.value = result.data.data.rows;
            total.value = result.data.data.total;
        } else {
            ElMessage.error('查询失败，请联系后台人员')
        }
    } catch {
        ElMessage.error('获取失败，请检查网络')
    }
}
//单个删除
const deleteTrainingActivityMsgById = async (id: any) => {
    //判断是否删除
    const isConfirm = window.confirm('确定删除吗？')
    if (isConfirm) {
        //发送请求
        try {
            const result = await axios.delete(`/admin/trainingActivity/${id}`)
            if (result.data.code === 1) {
                ElMessage.success('删除成功')
                // 刷新表格
                getTrainingActivityMsg()
            } else {
                ElMessage.error('删除失败，请联系后台人员')
            }
        } catch {
            ElMessage.error('删除失败，请检查网络')
        }
    }
}
//批量删除
//获取复选框选中表格的数据
//表格信息数组
const trainingActivityMsg = ref([])
//id数组
const trainingActivityMsgIds = ref([])
const getTrainingActivityMsgBySelect = (val: any) => {
    trainingActivityMsg.value = val
}
const deleteTrainingActivityMsgByIds = async () => {
    //判断是否删除
    const isConfirm = window.confirm('确定删除吗？')
    //判断是否选中复选框
    if (trainingActivityMsg.value.length === 0) {
        ElMessage.error('请选择要删除的活动')
        return
    }
    if (isConfirm) {
        //获取id
        trainingActivityMsg.value.forEach((item: any) => { trainingActivityMsgIds.value.push(item.id) })
        //发送请求
        try {
            const result = await axios.delete(`/admin/trainingActivity/${trainingActivityMsgIds.value.join(',')}`)
            if (result.data.code === 1) {
                ElMessage.success('删除成功')
                // 刷新表格
                getTrainingActivityMsg()
            } else {
                ElMessage.error('删除失败，请联系后台人员')
            }
        } catch {
            ElMessage.error('删除失败，请检查网络')
        }
    }
}
// 新增培训活动
const addTrainingActivity = async () => {
    //时间判断 开展时间不能大于结束时间
    if (ruleForm.startTime > ruleForm.endTime) {
        ElMessage.error('开展时间不能大于结束时间')
        return
    }
    // 验证表单是否通过
    if (ruleForm.trainingName === '' || ruleForm.maxCapacity === '' || ruleForm.startTime === '' || ruleForm.endTime === null) {
        ElMessage.error('请填写完整信息')
        return
    }
    try {
        // 发送请求
        const result = await axios.post('/admin/trainingActivity', ruleForm);
        if (result.data.code === 1) {
            ElMessage.success('新增成功');
            // 清空表单
            resetForm(ruleFormRef.value);
            // 刷新表格
            getTrainingActivityMsg();
            // 关闭对话框
            dialogVisible.value = false;
        } else {
            ElMessage.error('新增失败，请联系后台人员');
        }
    } catch (error) {
        // 捕获异常并显示错误信息
        ElMessage.error('新增失败，请检查网络');
    }
}
//获取单个培训活动的信息
const getTrainingActivityMsgById = (id: any) => {
    //显示修改对话框
    modifyDialogVisible.value = true;
    //发送请求
    axios.get(`/admin/trainingActivity/${id}`).then((res) => {
        if (res.data.code === 1) {
            modifyForm.id = res.data.data.id;
            modifyForm.trainingName = res.data.data.trainingName;
            modifyForm.maxCapacity = res.data.data.maxCapacity;
            modifyForm.startTime = res.data.data.startTime;
            modifyForm.endTime = res.data.data.endTime;
            //对获得状态进行处理
            modifyForm.activityStatus = res.data.data.activityStatus === 1 ? '1' : '2';
        } else {
            ElMessage.error('获取信息失败，请联系后台人员')
        }
    }).catch(() => {
        ElMessage.error('获取信息失败，请检查网络')
    })
}
//修改表格信息后发送请求
const modifyTrainingActivityMsg = async () => {
    try {
        const result = await axios.put('/admin/trainingActivity', modifyForm)
        if (result.data.code === 1) {
            ElMessage.success('修改成功')
            // 刷新表格
            getTrainingActivityMsg()
            // 关闭对话框
            modifyDialogVisible.value = false
        } else {
            ElMessage.error('修改失败，请联系后台人员')
        }
    } catch {
        ElMessage.error('修改失败，请检查网络')
    }
}
//获取员工培训活动对于的唯一id
let empTAId = ref()
const getEmpTrainingActivityId = (id: any) => {
    empTAId.value = id;
    //获取数据
    getEmpTrainingActivityMsg()
    //显示对话框
    tableDialogVisible.value = true;
}

//获取员工培训活动报名表信息
const getEmpTrainingActivityMsg = async () => {
    //发送请求
    try {
        const result = await axios.get(`/admin/empTrainingActivity?page=${empCurrentPage.value}&pageSize=${empPageSize.value}
        &name=${table.name}&account=${table.account}&gender=${table.gender}&activityDuration=${table.activityDuration}&activityStatus=${table.activityStatus}
        &activityScore=${table.activityScore}&id=${empTAId.value}&startTime=${table.registrationTime[0]}&endTime=${table.registrationTime[1]}`)
        if (result.data.code === 1) {
            //判断是否是查询
            if (table.name !== '' || table.account !== '' || table.registrationTime[0] !== '' || table.registrationTime[1] !== '' ||
                table.activityDuration !== '' || table.activityStatus !== '' || table.activityScore !== '') {
                ElMessage.success('查询成功')
            }
            userTableData.value = result.data.data.rows;
            empTotal.value = result.data.data.total;
        } else {
            ElMessage.error('查询失败，请联系后台人员')
        }
    } catch {
        ElMessage.error('获取失败，请检查网络')
    }
}
//单个删除根据员工账号
const deleteEmpTrainingActivityMsgById = async (account: any) => {
    //判断是否删除
    const isConfirm = window.confirm('确定删除吗？')
    if (isConfirm) {
        //发送请求
        try {
            const result = await axios.delete(`/admin/empTrainingActivity/${account}`)
            if (result.data.code === 1) {
                ElMessage.success('删除成功')
                // 刷新表格
                getEmpTrainingActivityMsg()
            } else {
                ElMessage.error('删除失败，请联系后台人员')
            }
        } catch {
            ElMessage.error('删除失败，请检查网络')
        }
    }
}
//获取复选框选中表格的数据
//表格信息数组
const empTrainingActivityMsg = ref([])
//id数组
const empTrainingActivityMsgAccounts = ref([])
const getEmpTrainingActivityMsgBySelect = (val: any) => {
    empTrainingActivityMsg.value = val
}
//批量删除根据员工账号
const deleteEmpTrainingActivityMsgByIds = async () => {
    //判断是否选中
    if (empTrainingActivityMsg.value.length === 0) {
        ElMessage.error('请选择要删除的员工')
        return
    }
    const isConfirm = window.confirm('确定删除吗？')
    if (isConfirm) {
        //获取id
        empTrainingActivityMsg.value.forEach((item: any) => { empTrainingActivityMsgAccounts.value.push(item.account) })
        //发送请求
        try {
            const result = await axios.delete(`/admin/empTrainingActivity/${empTrainingActivityMsgAccounts.value.join(',')}`)
            if (result.data.code === 1) {
                ElMessage.success('删除成功')
                // 刷新表格
                getEmpTrainingActivityMsg()
            } else {
                ElMessage.error('删除失败，请联系后台人员')
            }
        } catch {
            ElMessage.error('删除失败，请检查网络')
        }
    }
}
//全局员工账号
const empAccount = ref('')
//根据账号获取获取员工的分数
const getEmpTrainingActivityScoreByAccount = async (account: any) => {
    try {
        //获取员工分数回显到对话框
        const result = await axios.get(`/admin/empTrainingActivity/${account}/${empTAId.value}`)
        if (result.data.code === 1) {
            //回显数据
            score.value = result.data.data
            //显示对话框
            scoreDialogVisible.value = true;
            //赋值员工账号
            empAccount.value = account;
        } else {
            ElMessage.error('获取信息失败，请联系后台人员')
        }
    } catch (error) {
        ElMessage.error('获取信息失败，请检查网络')
    }
}
//监听分数的变化
const score = ref(0);
const firstScore = ref(0);
const changeScore = ref(0);
const endScore = ref(0) // 新增变量记录上一次的分数值

// 监听分数的变化，更严谨地计算并设置changeScore的值
watch(
    score,
    (newScore, oldScore) => {
        if (oldScore === 0) {
            changeScore.value = 0;
            firstScore.value = newScore;
        } else {
            endScore.value = newScore;
        }
    },
    { immediate: true }
);
// 打分=>修改员工的分数
const mark = async () => {
    changeScore.value = endScore.value - firstScore.value;
    console.log(changeScore.value)
    //根据员工账号打分
    //发送请求
    try {
        const result = await axios.put(`/admin/empTrainingActivity/${empAccount.value}`, { activityScore: score.value, changeScore: changeScore.value })
        if (result.data.code === 1) {
            ElMessage.success('打分成功')
            // 刷新表格
            getEmpTrainingActivityMsg()
            // 关闭对话框
            scoreDialogVisible.value = false
        } else {
            ElMessage.error('打分失败，请联系后台人员')
        }
    } catch {
        ElMessage.error('打分失败，请检查网络')
    }
}
</script>

<style></style>